﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InspectionMAC.Forms
{
    public partial class AlarmForm : Form
    {
        public AlarmForm()
        {
            InitializeComponent();
            // 确保窗体不会阻塞
            this.DoubleBuffered = true; // 添加双缓冲
        }

        private void AlarmForm_Load(object sender, EventArgs e)
        {
            // 确保UI线程响应
            Application.DoEvents();

            // 设置默认光标
            this.Cursor = Cursors.Default;
            label1.Cursor = Cursors.Default;
        }
        private void OnFormClosing(object sender, EventArgs e)
        {
            MacTestForm.alarm_Form = null;
        }
        public void UpdateAlarmString(string str)
        {
            if (this.IsDisposed) return; // 添加 disposed 检查

            if (label1.InvokeRequired)
            {
                // 使用更安全的Invoke方式
                if (!label1.IsDisposed)
                {
                    label1.BeginInvoke((MethodInvoker)delegate
                    {
                        if (!label1.IsDisposed)
                            label1.Text = str;
                    });
                }
            }
            else
            {
                if (!label1.IsDisposed)
                    label1.Text = str;
            }
        }
    }
}
